package
{
    import com.pblabs.engine.PBE;

    import com.pblabs.engine.entity.IEntity;
    import com.pblabs.engine.entity.PropertyReference;
    import com.pblabs.engine.entity.allocateEntity;
    import com.pblabs.rendering2D.IScene2D;
    import com.pblabs.rendering2D.SimpleShapeRenderer;
    import com.pblabs.rendering2D.ui.SceneView;

    import flash.geom.Point;

    // Set the initial size of the application, and define the
    // maximum frame rate
    [SWF(width="640", height="480", frameRate="60")]
    public class HelloWorld extends SceneView
    {
        public function HelloWorld()
        {
            // Start the PushButton Engine
            PBE.startup(this);
            // Initialize some default PushButton components
            PBE.initializeScene(this);

            // Create a component to draw a shape on the screen
            var shapeRenderer:SimpleShapeRenderer =
                new SimpleShapeRenderer();
            // Set the reference to the scene
            shapeRenderer.scene =
                PBE.lookupComponentByType("SceneDB", IScene2D) as IScene2D ;
            // Set the position of the shape drawn on the screen
            shapeRenderer.position = new Point(
                stage.stageWidth / 2,
                stage.stageHeight / 2);

            var keyboardController:KeyboardControllerComponent =
                new KeyboardControllerComponent();
            keyboardController.positionReference =
                new PropertyReference("@Render.position");

            var colorModifier:ColorModifierComponent =
                new ColorModifierComponent();
            colorModifier.colorReference =
                new PropertyReference("@Render.fillColor");

            // Create an entity to hold the component
            var entity:IEntity = allocateEntity();
            // Initialize the Entity with the supplied name
            entity.initialize("TestEntity");
            // Add the components to the Entity
            entity.addComponent(shapeRenderer, "Render");
            entity.addComponent(keyboardController, "KeyboardController");
            entity.addComponent(colorModifier, "ColorModifier");
        }
    }
}